package com.ruoyi.web.controller.saas;

import com.bonuo.saas.domain.Event;
import com.bonuo.saas.domain.ReceiptInfo;
import com.bonuo.saas.service.EventService;
import com.bonuo.saas.service.ReceiptInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 服务事件Controller
 */
@Api(tags = "回执信息")
@RestController
@RequestMapping("/saas/receiptInfo")
public class ReceiptInfoController extends BaseController {
    @Autowired
    private ReceiptInfoService receiptInfoService;

    @ApiOperation(value = "查询回执信息列表",httpMethod = "GET")
    @GetMapping("/list")
    public AjaxResult list(ReceiptInfo receiptInfo,Integer pageNum,Integer pageSize) {
        if(pageNum != null && pageSize != null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<ReceiptInfo> list = receiptInfoService.selectReceiptInfoList(receiptInfo);
        return success(new PageInfo<>(list));
    }

    @ApiOperation(value = "添加回执信息",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ReceiptInfo receiptInfo) {
        return toAjax(receiptInfoService.insertReceiptInfo(receiptInfo));
    }

    @ApiOperation(value = "修改回执信息",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody ReceiptInfo receiptInfo) {
        return toAjax(receiptInfoService.updateReceiptInfo(receiptInfo));
    }

    @ApiOperation(value = "删除回执信息",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id) {
        return toAjax(receiptInfoService.deleteReceiptInfoById(id));
    }
}